<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.org/ui" xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<f:metadata>
 		<f:event listener="#{MusteriAygitlariBean.verifyMusteriAygit}" type="preRenderView"/>		
	</f:metadata>
</h:head>
<h:body>
	<ui:composition template="template.xhtml">

		<ui:define name="title">mehmet emmy</ui:define>
		<ui:define name="body">
			
			<h:form id="musteriUrunForm">
				<p:growl id="messages" showDetail="true" life="3000"/>
				<c:choose>
					<c:when test="${MusteriAygitlariBean.selectedMusAygit != null}">
						<p:commandButton id="backButton" value="Geri Dön" icon="ui-icon-search"
							actionListener="#{MusteriAygitlariBean.clear}"
							update=":musteriUrunForm" />
						<c:choose>
							<c:when test="#{MusteriAygitlariBean.islemTuru == 'new'}">
								<ui:include src="musUrunEkle.xhtml" />
							</c:when>
							<c:when test="#{MusteriAygitlariBean.islemTuru == 'ihbar'}">
								<ui:include src="aygitihbar.xhtml" />
							</c:when>
							<c:when test="#{MusteriAygitlariBean.islemTuru == 'log'}">
								<ui:include src="logs.xhtml" />
							</c:when>
							<c:otherwise>
								işlem türü : #{MusteriAygitlariBean.islemTuru}
							</c:otherwise>
						</c:choose>
					</c:when>
					<c:otherwise>

						<p:dataTable id="urunAramaTable" var="urun"
							value="#{MusteriAygitlariBean.musAygitlariList}" widgetVar="urunlerTable"
							resizableColumns="true"
							emptyMessage="No product found with given criteria"
							rowKey="#{urun.aygitSeriNo}"
							selection="#{MusteriAygitlariBean.selectedMusAygit}"
							selectionMode="single" paginator="true" rows="10" liveScroll="true">											
							
							<f:facet name="header">
								<p:outputPanel>
									<h:outputText value="Search all fields:" />
									<p:inputText id="globalFilter" onkeyup="urunlerTable.filter()"
										style="width:150px" />
								</p:outputPanel>
							</f:facet>

							<p:column id="sirketAdColumn"
								filterBy="#{urun.aygit.sirketprofil.firmaAd}" headerText="Firma Adı"
								footerText="startsWith">
								<h:outputText value="#{urun.aygit.sirketprofil.firmaAd}" />
							</p:column>

							<p:column id="aygitsrnNoColumn" filterBy="#{urun.aygitSeriNo}"
								headerText="Aygıt Seri No" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygitSeriNo}" />
							</p:column>
							
							<p:column id="aygitTuruColumn" filterBy="#{urun.aygit.aygitTuru}"
								headerText="Aygıt Türü" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.aygitTuru}" />
							</p:column>
							
							<p:column id="aygtTurColumn" filterBy="#{urun.aygit.marka} - #{urun.aygit.model}" 
								headerText="Marka-Model" footerText="contains" filterMatchMode="contains">
								<h:outputText id="marka-model"
									value="#{urun.aygit.marka} - #{urun.aygit.model}" />
							</p:column>
							<f:facet name="footer">
								<p:commandButton id="logButton" value="Aygıt log"
									action="#{LoglarBean.getAygitLogs}"
									actionListener="#{MusteriAygitlariBean.setIslemTuru('log')}"
									update=":musteriUrunForm" icon="ui-icon-search" />									
							</f:facet>
							<f:facet name="footer">
								<p:splitButton value="İhbar" 
									action="#{AygitihbarBean.viewNew}" id="ihbarButton"
									update=":musteriUrunForm" icon="ui-icon-disk">  
        							<p:menuitem value="İhbarlarım"  id="myihbBtn"
        								actionListener="#{AygitihbarBean.getMusteriIhbarlari}"
        								icon="ui-icon-arrowrefresh-1-w" 
        								update=":musteriUrunForm:ihbarList, :musteriUrunForm:messages"/>  
							    </p:splitButton>
							</f:facet>
							
							<f:facet name="footer">
								<p:commandButton id="deleteButton" value="Delete"
									icon="ui-icon-trash"
									action="#{MusteriAygitlariBean.deleteView}"
									update=":musteriUrunForm" />
							</f:facet>
							
							<f:facet name="footer">
								<p:commandButton id="newButton" value="Add New"
									icon="ui-icon-document"
									action="#{MusteriAygitlariBean.viewNew}"
									actionListener="#{MusteriAygitlariBean.setIslemTuru('new')}"
									update=":musteriUrunForm"/>
							</f:facet>
						</p:dataTable>
							
						<p:overlayPanel id="myihbPanel" for=":musteriUrunForm:urunAramaTable:myihbBtn" 
							hideEffect="fade" widgetVar="mypanel" >
								<p:contextMenu for="ihbarList">
									<p:menuitem value="Delete" update="ihbarList"
										icon="ui-icon-close"
										action="#{AygitihbarBean.deleteView}" oncomplete="mypanel.hide()"/>
									<p:menuitem value="Detail"
										icon="ui-icon-search" oncomplete="ihbIslemDlg.show()" />
								</p:contextMenu>
								
								<p:dataTable id="ihbarList" var="ihbList"
									rowKey="#{ihbList.ihbarid}" selectionMode="single" 
									selection="#{AygitihbarBean.selectedAygitihbar}" 
									value="#{AygitihbarBean.aygitihbarList}">
										<f:facet name="header">  
            								İhbarlarım 
        							</f:facet>

									<p:column id="modelHeader">
										<f:facet name="header">  
                   							Aygıt marka-model  
           								</f:facet>
										<h:outputText value="#{ihbList.musteriaygitlari.aygit.marka}
										- #{ihbList.musteriaygitlari.aygit.model}" />
									</p:column>
									<p:column>
										<f:facet name="header">  
                   							Seri No 
        								</f:facet>
									<h:outputText value="#{ihbList.musteriaygitlari.aygitSeriNo}" />
									</p:column>

									<p:column>
										<f:facet name="header">  
				                    		Açıklama  
           								</f:facet>
										<h:outputText value="#{ihbList.aciklamalar}" />
									</p:column>

								</p:dataTable>
							</p:overlayPanel>
						<p:dialog id="ihbarDialog" header="İhbar Düzenleme"
							widgetVar="ihbIslemDlg" dynamic="true" resizable="false"
							width="400" height="200" showEffect="clip" hideEffect="fold">
							<h:panelGrid id="display" columns="2" cellpadding="4">

								<h:outputLabel value="Aygıt marka-model : " />
								<h:outputText
									value="#{AygitihbarBean.selectedAygitihbar.musteriaygitlari.aygit.marka}
			 - #{AygitihbarBean.selectedAygitihbar.musteriaygitlari.aygit.model}" />

								<h:outputLabel value="Aygıt Seri No : " />
								<h:outputText
									value="#{AygitihbarBean.selectedAygitihbar.musteriaygitlari.aygitSeriNo}" />

								<h:outputLabel value="İhbar Tarihi : " />
								<h:outputText
									value="#{AygitihbarBean.selectedAygitihbar.ihbarTarihi}" />

								<h:outputLabel value="Kayıp/Çalıntı Tarihi : " />
								<p:calendar
									value="#{AygitihbarBean.selectedAygitihbar.kayipCalintiTarihi}"
									id="popupCal2" converter="DateConverter" pattern="dd/MM/yyyy"
									maxdate="#{AygitihbarBean.selectedAygitihbar.ihbarTarihi}" showOn="button"
									style="height:150px; width:140px;" showWeeksBar="false"
									readOnlyInputText="true" />								

								<h:outputLabel value="İhbar Açıklama : " />
								<h:inputTextarea style="width:220px; height:50px;"
									value="#{AygitihbarBean.selectedAygitihbar.aciklamalar}" />
								<p:separator /> <p:separator />
								
								<h:outputText/>
								<p:commandButton value="Submit"  update=":musteriUrunForm"
									action="#{AygitihbarBean.SaveOrUpdate}" id="btnSubmit" />
							</h:panelGrid>
						</p:dialog>
					</c:otherwise>
				</c:choose>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>